<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <!-- jsp文件头和头部 -->
    <%@ include file="../admin/top.jsp" %>
    <%--    常见问题-问题类别--%>
    <style>
        table tr td img {
            height: 25px;
            border-radius: 8%;
        }
    </style>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <form action="feedback/list" method="post" name="userForm" id="userForm">
                    <input type="hidden" name="menuId" value="${page.menuId}">
                    <table style="width: 500px">
                        <tr>
                            <td>
                                <span class="input-icon">
                                    <input style="margin-top: 0px;width: 85%" autocomplete="off" type="text"
                                           name="searchValue" value="${page.searchValue}" placeholder="查找邮箱" />
                                </span>
                            </td>
                            <td>
                                <span class="input-icon">
                                    <input style="margin-top: 0px;width: 85%" autocomplete="off" type="text"
                                           name="searchContent" value="${searchContent}" placeholder="查找反馈内容" />
                                </span>
                            </td>
                            <td>
                                <select class="chzn-select" name="pass" data-values="${pass}"
                                        data-placeholder="处理状态" style="vertical-align:top;width: 120px;">
                                    <option value="">处理状态</option>
                                    <option value="1"
                                            <c:if test="${pass == 1}">selected</c:if> >已处理
                                    </option>
                                    <option value="0"
                                            <c:if test="${pass == 0}">selected</c:if> >待处理
                                    </option>
                                </select>
                            </td>
                            <td style="vertical-align:top;">
                                <button class="btn btn-mini btn-light" type="button" onclick="search();" title="检索">
                                    <i id="nav-search-icon" class="icon-search"></i>
                                </button>
                            </td>
                        </tr>
                    </table>
                    <!-- 检索  -->
                    <table id="table_report" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>用户ID</th>
                            <th>用户邮箱</th>
                            <th>反馈内容</th>
                            <th>处理状态</th>
                            <th>创建时间</th>
                            <th class="center">操作</th>
                        </tr>
                        </thead>
                        <tbody id="contentTbody">
                        <!-- 开始循环 -->
                        <c:choose>
                            <c:when test="${not empty feedbackList}">
                                <c:forEach items="${feedbackList}" var="item">
                                    <tr style="text-align: center">
                                        <td>${item.id}</td>
                                        <td>${item.openid}</td>
                                        <td>${item.email}</td>
                                        <td>${item.content}</td>
                                        <td>${item.pass}</td>
                                        <td>
                                            <fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                                        </td>
                                        <td style="width: 60px;">
                                            <div class='hidden-phone visible-desktop btn-group'>
                                                <c:if test="${fn:contains(butSet, 'pass')}">
                                                    <c:if test="${item.pass == 0}">
                                                        <a class='btn btn-mini btn-danger'
                                                           onclick="changePass('${item.id}', 1);">
                                                            标记已处理
                                                        </a>
                                                    </c:if>
                                                    <c:if test="${item.pass == 1}">
                                                        <a class='btn btn-mini btn-danger'
                                                           onclick="changePass('${item.id}', 0);">
                                                            标记未处理
                                                        </a>
                                                    </c:if>
                                                </c:if>
                                                <c:if test="${fn:contains(butSet, 'del')}">
                                                    <a class='btn btn-mini btn-danger' title="删除"
                                                       onclick="del('${item.id }');">
                                                        <i class='icon-trash'></i>
                                                    </a>
                                                </c:if>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <tr class="main_info">
                                    <td colspan="10" class="center">没有相关数据</td>
                                </tr>
                            </c:otherwise>
                        </c:choose>
                        </tbody>
                    </table>
                    <div class="page-header position-relative">
                        <table style="width:100%;">
                            <tr>
                                <td style="vertical-align:top;">
                                    <div class="pagination"
                                         style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
    <i class="icon-double-angle-up icon-only"></i>
</a>
<!-- 引入 -->
<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/ace-elements.min.js"></script>
<script src="static/js/ace.min.js"></script>

<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
<!-- 引入 -->
<script type="text/javascript" src="static/js/jquery.tips.js"></script><!--提示框-->
<script type="text/javascript">
    $(function () {
        top.hangge();
        //下拉框
        $(".chzn-select").chosen({disable_search: true});
        $(".chzn-select-deselect").chosen({allow_single_deselect: true});
    });

    //检索
    function search() {
        top.jzts();
        $("#userForm").submit();
    }


    //标记为 type: 0:标记为未处理 1: 标记为已处理
    function changePass(id, type) {
        var tempStr = "是否标记为已处理";
        if (type == 0) {
            tempStr = "是否重新标记成未处理";
        }
        bootbox.confirm(tempStr+"?", function (result) {
            if (result) {
                top.jzts();
                var url = "<%=basePath%>feedback/changePass";
                var param = {"id":id, "pass":type ,"tm":new Date().getTime(), "menuId":"${page.menuId}" };

                $.post(url, param, function (data) {
                    if (data.code == 200) {
                        // alert("成功! "+data.msg);
                        nextPage(${page.currentPage});
                    } else {
                        alert(data.msg)
                    }
                });
            }
        });
    }

    //删除
    function del(id) {
        bootbox.confirm("是否删除[" + id + "]?", function (result) {
            if (result) {
                top.jzts();
                var postParam = {"id": id};
                var url = "<%=basePath%>feedback/del";
                $.post(url, postParam, function (data) {
                    if (data.code == 200) {
                        alert("删除成功")
                        nextPage(${page.currentPage});
                    } else {
                        alert(data.msg)
                    }
                });
            }
        });
    }

</script>
</body>
</html>
